import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Test4 {

    public static void main(String[] args) throws SQLException {
        update(null, "aa", "bb", 1, 1);
    }

    public static void update(Connection conn, String certType, String certCode, int addReduce, int num) throws SQLException {

        StringBuffer sqlStr = new StringBuffer(" ");
        StringBuffer insertHisSql = new StringBuffer(" ");
        String tableName = "cert_owner_num";
        String tableNameHis = "cert_owner_num_H" + new Date();
        insertHisSql.append(" insert into ").append(tableNameHis).append("(owner_cert_type, owner_cert_code, owner_num, create_time, done_date)");
        sqlStr.append("update ").append(tableName).append(" set owner_num ").append(" = ");

        if (addReduce == 1) {
            sqlStr.append(" owner_num+" + num);
        }else if(addReduce == -1) {
            sqlStr.append(" owner_num-" + num);
        }else {
            sqlStr.append(" owner_num ");
        }

        sqlStr.append(", done_date = sysdate ");
        sqlStr.append(" where owner_cert_type = :cerType and owner_cert_code = :cerCode ");
        Map paramMap = new HashMap();
        paramMap.put("certType", certType);
        paramMap.put("certCode", certCode);

        String sql = new String(sqlStr);
//            PreparedStatement statement = conn.prepareStatement(sql);
    }
}
